import rxAjax from '@/assets/js/ajax.js';

//常用脚本 api接口
export const FormCommonScriptApi = {};

FormCommonScriptApi.baseUrl= '/api-form/form/core/formCommonScript';
FormCommonScriptApi.exportUrl= FormCommonScriptApi.baseUrl + '/listExport';

//查询列表
FormCommonScriptApi.query=function (parameter) {
  var url= FormCommonScriptApi.baseUrl + '/query';
  return rxAjax.postJson(url,parameter).then (res => {
    return res.result
  })
}

/**
* 获取单记录
* @param pkId
* @returns {*}
*/
FormCommonScriptApi.get =function(pkId) {
  var url= FormCommonScriptApi.baseUrl + '/get?pkId=' + pkId;
  return rxAjax.get(url);
}

//保存数据
FormCommonScriptApi.save =function(parameter) {
  var url= FormCommonScriptApi.baseUrl + '/save';
  return rxAjax.postJson(url,parameter);
}

//删除数据
FormCommonScriptApi.del =function(parameter) {
  var url= FormCommonScriptApi.baseUrl + '/del';
  return rxAjax.postUrl(url,parameter);
}

//获取常用脚本
FormCommonScriptApi.getCommonScriptByUse =function(useTO) {
    var url= FormCommonScriptApi.baseUrl + '/getCommonScriptByUse?useTO=' + useTO;
    return rxAjax.get(url);
}

//获取常用脚本
FormCommonScriptApi.getTypeByUse =function(useTO) {
    var url= FormCommonScriptApi.baseUrl + '/getTypeByUse?useTO=' + useTO;
    return rxAjax.get(url);
}

export  default FormCommonScriptApi;

